package com.chixing.day08_interface;

public class Product implements Comparable<Product>{
    private String proName;
    private int proSale;
    private float proPrice;

    public Product(String name, int sale, float price) {
        this.proName=name;
        this.proSale=sale;
        this.proPrice=price;
        System.out.println(name + "  " + sale + "  " +  price );
    }

    //两个商品比较先后顺序  先比较销量  在比较价格  在比较商品名称
    @Override
    public int compareTo(Product anoterProduct){
        if(this.proSale!=anoterProduct.proSale){
           return this.proSale - anoterProduct.proSale;
        }else if(this.proPrice!=anoterProduct.proPrice){
            return (int) (this.proPrice - anoterProduct.proPrice);

        } else{
            return this.proName.compareTo(anoterProduct.proName);
        }
    }

    public String getProName() {
        return proName;
    }

    public void setProName(String proName) {
        this.proName = proName;
    }

    public int getProSale() {
        return proSale;
    }

    public void setProSale(int proSale) {
        this.proSale = proSale;
    }

    public float getProPrice() {
        return proPrice;
    }

    public void setProPrice(float proPrice) {
        this.proPrice = proPrice;
    }


}
